#-*- coding: UTF-8 -*-
import os,sys
import time
import unittest
from appium import webdriver
import xlrd
import xlwt
import traceback
from readexcel import excel_action
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.touch_actions import TouchActions
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from sendEmail import SendMail


desired_caps={}
desired_caps['platformName']='Android'
# desired_caps['version']='8.0.0'
# desired_caps['deviceName']='VPL6R18A29002470'#这是测试机的型号，可以查看手机的关于本机选项获得
# desired_caps['version']='7.1.1'
# desired_caps['deviceName']='HGAFQ94U'#这是测试机的型号，可以查看手机的关于本机选项获得
desired_caps['version']='8.1.0'
desired_caps['deviceName']='9435cb1'#这是测试机的型号，可以查看手机的关于本机选项获得
#
# desired_caps['version']='7.1.0'
# desired_caps['deviceName']='127.0.0.1:21503'#这是测试机的型号，可以查看手机的关于本机选项获得
# #模拟器
# desired_caps['version']='7.1.2'
# desired_caps['deviceName']='emulator-5554'#这是测试机的型号， 可以查看手机的关于本机选项获得

desired_caps['unicodeKeyboard'] = 'true' # 使用unicode编码方式发送字符串
desired_caps['resetKeyboard'] = 'true'   # 隐藏键盘
# desired_caps['app'] = PATH('D:\\qq.apk')#被测试的App在电脑上的位置
desired_caps['recreateChromeDriverSessions'] = 'True'
desired_caps['appPackage'] = 'cn.com.fwd.eapp.uat'
desired_caps['appActivity'] = 'cn.com.fwd.eapp.uat.activity.SplashActivity'
desired_caps['chromedriverExecutableDir'] = r'D:\workspace\webdriver\chrome\2.43\chromedriver\chromedriver_win32_2.41'
desired_caps['recreateChromeDriverSessions'] = 'True'


driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps)
time.sleep(2)
#选择环境
driver.switch_to.context("NATIVE_APP")
size=driver.get_window_size() #获取手机屏幕大小,分辨率
print(size)#{'width': 720, 'height': 1280}
time.sleep(1)
ell = driver.find_element_by_xpath\
    ("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.support.v7.widget.LinearLayoutCompat/android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.EditText")
ell.click()
ell.send_keys("4")
#driver.hide_keyboard()
time.sleep(2)
ell2= driver.find_element_by_id("android:id/button1")
ell2.click()
#输入用户名密码
time.sleep(1)
webview = driver.contexts
print(webview)
view=webview[1]
driver.switch_to.context(view)
new_view = driver.current_context

driver.find_element_by_id("account").send_keys("10000796")
driver.find_element_by_id("password").send_keys("080092")
time.sleep(2)

login = driver.find_element_by_xpath("//*[@id='formLogin']/button")
# TouchActions(driver).tap(login).perform()
login.send_keys(Keys.ENTER)
time.sleep(8)
filename ='D:\\workspace\\smart\\venv1\\data\\AugustVersion.xlsx'

excelread = xlrd.open_workbook(filename)
table = excelread.sheet_by_name('Sheet1')
h = table.nrows

def getSize():
    x = driver.get_window_size()['width']
    y = driver.get_window_size()['height']
    return (x, y)

# 屏幕向上滑动g
def swipeUp(t):
    l = getSize()
    x1 = int(l[0] * 0.5)  # x坐标
    y1 = int(l[1] * 0.75)  # 起始y坐标
    y2 = int(l[1] * 0.25)  # 终点y坐标
    driver.swipe(x1, y1, x1, y2, t)
# 屏幕向下滑动
def swipeDown(t):
    l = getSize()
    x1 = int(l[0] * 0.5)  # x坐标
    y1 = int(l[1] * 0.25)  # 起始y坐标
    y2 = int(l[1] * 0.75)  # 终点y坐标
    driver.swipe(x1, y1, x1, y2, t)
# 屏幕向左滑动

def swipLeft(t):
    l = getSize()
    x1 = int(l[0] * 0.75)
    y1 = int(l[1] * 0.5)
    x2 = int(l[0] * 0.05)
    driver.swipe(x1, y1, x2, y1, t)
# 屏幕向右滑动
def swipRight(t):
    l = getSize()
    x1 = int(l[0] * 0.05)
    y1 = int(l[1] * 0.5)
    x2 = int(l[0] * 0.75)
    driver.swipe(x1, y1, x2, y1, t)
def notId():
    # driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
    # time.sleep(2)
    # a23 = driver.find_element_by_xpath("//*[@id='insuredInfo']/section/div/ul/li[1]")
    # time.sleep(1)
    # TouchActions(driver).tap(a23).perform()
    # time.sleep(5)
    driver.switch_to.context("NATIVE_APP")
    time.sleep(1)
    # 被保人拍照
    driver.tap([(1770, 590)], 1000)
    time.sleep(10)
    driver.tap([(1770, 590)], 1000)
    time.sleep(10)
    driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
    time.sleep(5)
    # 被保人证件号
    driver.find_element_by_xpath("//*[@id='insuredInfo']/div/ul[2]/li[1]/input").click()
    driver.find_element_by_xpath("//*[@id='insuredInfo']/div/ul[2]/li[1]/input").send_keys(list_login[11])
    # 有效期至
    if list_login[4] == '长期':
        driver.find_element_by_xpath("//*[@id='insuredInfo']/div/ul[2]/li[2]/div[2]/label/input").click()
    else:
        js = "document.getElementById('date-yxq').removeAttribute('readonly')"
        driver.execute_script(js)
        time.sleep(2)
        driver.find_element_by_id("date-yxq").send_keys(list_login[12])
    time.sleep(1)
    driver.find_element_by_name("jobCode").send_keys(list_login[16])
    js1 = "document.getElementById('date-csrq').removeAttribute('readonly')"
    driver.execute_script(js1)
    driver.find_element_by_id("date-csrq").send_keys(list_login[14])
    time.sleep(1)
    driver.find_element_by_id("date-csrq").click()
    time.sleep(2)
    driver.switch_to.context("NATIVE_APP")
    driver.tap([(1812, 750)], 500)
    time.sleep(2)
    driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
    if list_login[15] == '男':
        a20 = driver.find_element_by_xpath("//*[@id='insuredInfo']/div/ul[2]/li[5]/div/label[1]")
        TouchActions(driver).tap(a20).perform()
    else:
        a20 = driver.find_element_by_xpath("//*[@id='insuredInfo']/div/ul[2]/li[5]/div/label[2]")
        TouchActions(driver).tap(a20).perform()
    # 被保人姓名
    driver.find_element_by_xpath("//*[@id='insuredInfo']/div/ul[2]/li[3]/input").send_keys(list_login[13])
    # 职位信息
    time.sleep(2)
    # 点击保存
    a30 = driver.find_element_by_xpath("//*[@id='insuredInfo']/div/div/div/button")
    TouchActions(driver).tap(a30).perform()
    time.sleep(2)
def insuredperson():
    driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
    time.sleep(2)
    #点击保存
    a22 = driver.find_element_by_css_selector(".btn.btn-submit.btn-save")
    time.sleep(1)
    TouchActions(driver).tap(a22).perform()
    #选择被保人证件号
    time.sleep(5)
    if list_login[10] == "身份证":
        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
        time.sleep(2)
        a23 = driver.find_element_by_xpath("//*[@id='insuredInfo']/section/div/ul/li[1]")
        time.sleep(1)
        TouchActions(driver).tap(a23).perform()
        time.sleep(5)
        driver.switch_to.context("NATIVE_APP")
        time.sleep(1)
        # 被保人拍照
        driver.tap([(1770, 590)], 1000)
        time.sleep(10)
        driver.tap([(1770, 590)], 1000)
        time.sleep(10)
        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
        time.sleep(5)
        #被保人证件号
        driver.find_element_by_xpath("//*[@id='insuredInfo']/div/ul[2]/li[1]/input").click()
        driver.find_element_by_xpath("//*[@id='insuredInfo']/div/ul[2]/li[1]/input").send_keys(list_login[11])
        #有效期至
        if list_login[4] == '长期':
            driver.find_element_by_xpath("//*[@id='insuredInfo']/div/ul[2]/li[2]/div[2]/label/input").click()
        else:
            js = "document.getElementById('date-yxq').removeAttribute('readonly')"
            driver.execute_script(js)
            time.sleep(2)
            driver.find_element_by_id("date-yxq").send_keys(list_login[12])
        time.sleep(1)
        driver.find_element_by_name("jobCode").send_keys(list_login[16])
        #被保人姓名
        driver.find_element_by_xpath("//*[@id='insuredInfo']/div/ul[2]/li[3]/input").send_keys(list_login[13])
        #职位信息
        time.sleep(2)
        # 点击保存
        a30 = driver.find_element_by_xpath("//*[@id='insuredInfo']/div/div/div/button")
        TouchActions(driver).tap(a30).perform()
        time.sleep(2)

    elif list_login[10] == "护照":
        a24 = driver.find_element_by_xpath("//*[@id='insuredInfo']/section/div/ul/li[2]")
        time.sleep(1)
        TouchActions(driver).tap(a24).perform()
        time.sleep(3)
        notId()
    elif list_login[10] == "出生证":
        a25 = driver.find_element_by_xpath("//*[@id='insuredInfo']/section/div/ul/li[3]")
        time.sleep(1)
        TouchActions(driver).tap(a25).perform()
        time.sleep(3)
        notId()
    elif list_login[10] == "军官证":
        a26 = driver.find_element_by_xpath("//*[@id='insuredInfo']/section/div/ul/li[4]")
        time.sleep(1)
        TouchActions(driver).tap(a26).perform()
        time.sleep(3)
        notId()
    elif list_login[10] == "台胞证":
        a27 = driver.find_element_by_xpath("//*[@id='insuredInfo']/section/div/ul/li[5]")
        time.sleep(1)
        TouchActions(driver).tap(a27).perform()
        time.sleep(3)
        notId()
    elif list_login[10] == "港澳回乡证":
        a28 = driver.find_element_by_xpath("//*[@id='insuredInfo']/section/div/ul/li[6]")
        time.sleep(1)
        TouchActions(driver).tap(a28).perform()
        time.sleep(3)
        notId()
    elif list_login[10] == "户口簿":
        a29 = driver.find_element_by_xpath("//*[@id='insuredInfo']/section/div/ul/li[7]")
        time.sleep(1)
        TouchActions(driver).tap(a29).perform()
        time.sleep(3)
        notId()
def insurance():
    driver.switch_to.context("NATIVE_APP")
    time.sleep(2)
    driver.tap([(1770, 590)], 500)
    time.sleep(15)
    driver.tap([(1770, 590)], 500)
    time.sleep(15)
    driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
    time.sleep(1)
    #证件号
    driver.find_element_by_xpath("//*[@id='applicantInfo']/div/ul[2]/li[1]/input").click()
    driver.find_element_by_xpath("//*[@id='applicantInfo']/div/ul[2]/li[1]/input").send_keys(list_login[3])
    #有效期至
    if list_login[4] == '长期':
        driver.find_element_by_xpath("//*[@id='applicantInfo']/div/ul[2]/li[2]/div[2]/label/input").click()
    else:
        js="document.getElementById('date-yxq').removeAttribute('readonly')"
        driver.execute_script(js)
        time.sleep(2)
        driver.find_element_by_id("date-yxq").send_keys(list_login[4])
    #出生日期
    if list_login[2] != '身份证':
        js1 = "document.getElementById('date-csrq').removeAttribute('readonly')"
        driver.execute_script(js1)
        driver.find_element_by_id("date-csrq").send_keys(list_login[6])
        time.sleep(1)
        driver.find_element_by_id("date-csrq").click()
        time.sleep(2)
        driver.switch_to.context("NATIVE_APP")
        driver.tap([(1812, 750)], 500)
        time.sleep(2)
        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
        if list_login[7] == '男':
            a20= driver.find_element_by_xpath("//*[@id='applicantInfo']/div/ul[2]/li[5]/div/label[1]")
            TouchActions(driver).tap(a20).perform()
        else:
            a20 = driver.find_element_by_xpath("//*[@id='applicantInfo']/div/ul[2]/li[5]/div/label[2]")
            TouchActions(driver).tap(a20).perform()
    else:
        pass
    #姓名
    driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
    time.sleep(1)
    driver.find_element_by_xpath("//*[@id='applicantInfo']/div/ul[2]/li[3]/input").send_keys(list_login[5])
    time.sleep(1)
    #职位信息
    driver.find_element_by_name("jobCode").send_keys(list_login[8])
    time.sleep(3)
    try:
        oldperson = driver.find_element_by_css_selector(".customer-item")
    except NoSuchElementException:
        print("不是老客户")
    else:
        if list_login[73] == "新客户":
            Notme = driver.find_element_by_xpath("//*[@id='applicantInfo']/div[2]/div/div[3]/button[1]")
            #点击以上信息都不是我
            TouchActions(driver).tap(Notme).perform()
        else:
            TouchActions(driver).tap(oldperson).perform()
            time.sleep(3)
            try:
                Verification = driver.find_element_by_name("phoneCode")
            except NoSuchElementException:
                print("无验证码")
                confirm = driver.find_element_by_xpath("//*[@id='applicantInfo']/div[2]/div/div[3]/button[2]")
                time.sleep(4)
                TouchActions(driver).tap(confirm).perform()
            else:
                time.sleep(2)
                Verification.send_keys("999999")
                time.sleep(1)
                codeConfirm = driver.find_element_by_xpath("//*[@id='applicantInfo']/div[2]/div/div[2]/div/div[2]/div/button[2]")
                time.sleep(1)
                TouchActions(driver).tap(codeConfirm).perform()
                confirm = driver.find_element_by_xpath("//*[@id='applicantInfo']/div[2]/div/div[3]/button[2]")
                time.sleep(4)
                TouchActions(driver).tap(confirm).perform()

    time.sleep(5)
    if list_login[9] == "本人":
        time.sleep(2)
        driver.find_element_by_xpath("//*[@id='applicantInfo']/div/ul[3]/li[3]/div/label[1]").click()
        time.sleep(2)
        a40 =driver.find_element_by_xpath("//*[@id='applicantInfo']/div/div/div/button")
        TouchActions(driver).tap(a40).perform()
    elif list_login[9] == "父母":
        driver.find_element_by_xpath("//*[@id='applicantInfo']/div/ul[3]/li[3]/div/label[2]").click()
        insuredperson()
    elif list_login[9] == "配偶":
        driver.find_element_by_xpath("//*[@id='applicantInfo']/div/ul[3]/li[3]/div/label[3]").click()
        insuredperson()
    elif list_login[9] == "子女":
        driver.find_element_by_xpath("//*[@id='applicantInfo']/div/ul[3]/li[3]/div/label[4]").click()
        insuredperson()
    elif list_login[9] == "其他":
        driver.find_element_by_xpath("//*[@id='applicantInfo']/div/ul[3]/li[3]/div/label[1]").click()

#创建存保单号的excel
workbook = xlwt.Workbook()
sheet1 =workbook.add_sheet("issid")
row1=1
#获取当前时间
localtime = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))
time.sleep(2)
driver.switch_to.context("NATIVE_APP")
time.sleep(2)


for i in range(2,h):
    excel = excel_action()
    list_login = excel.read_excel_row(filename, 0, i)  # read excel data
    print(list_login)
    # driver.switch_to.context("NATIVE_APP")
    #time.sleep(8)
    try:
        # 点击在线投保
        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
        # a15 = WebDriverWait(driver,20,0.5).until(lambda x:x.find_element_by_xpath("//*[@id='outerDiv']/ul/li[4]/a/i"))
        a15 = driver.find_element_by_xpath("//*[@id='outerDiv']/ul/li[4]/a/i")
        TouchActions(driver).tap(a15).perform()
        time.sleep(3)
        if list_login[0] == "生命保障":
            # a16 = driver.find_element_by_css_selector("[data-code ='LIFENEW']")
            a16 = driver.find_element_by_xpath("//*[@id='selectProduct']/ul/li[1]")
            # a16.click()
            TouchActions(driver).tap(a16).perform()
            # TouchActions(driver).tap(a16).perform()
            # a16.click()
            # driver.switch_to.context("NATIVE_APP")
            # driver.tap([(126, 585)], 500)
            time.sleep(2)
            driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
            i = 14
            j = 0
            while i < 20:
                title = driver.find_elements_by_class_name("title")[i].text
                tagtop = driver.find_elements_by_class_name("tag-top-right")[j].text
                title2 = title + tagtop
                if title2 == list_login[1]:
                    print(title2)
                    # driver.find_elements_by_class_name("title")[i].click()
                    lifenew =driver.find_elements_by_class_name("title")[i]
                    time.sleep(2)
                    lifenew.send_keys(Keys.ENTER)
                    # TouchActions(driver).tap(lifenew).perform()
                    time.sleep(2)
                    break
                else:
                    i = i + 1
                    j = j + 1
            time.sleep(3)
        elif list_login[0] == '意外':
            a1 = driver.find_element_by_xpath("//*[@id='selectProduct']/ul/li[2]")
            TouchActions(driver).tap(a1).perform()
            time.sleep(4)
            driver.find_element_by_xpath("//*[text()='%s']" % list_login[1]).click()
            print(list_login[1])
        elif list_login[0] == '重疾':
            a2 = driver.find_element_by_xpath("//*[@id='selectProduct']/ul/li[3]")
            TouchActions(driver).tap(a2).perform()
            time.sleep(4)
            driver.find_element_by_xpath("//*[text()='%s']" % list_login[1]).click()
        elif list_login[0] == '理财':
            a3 = driver.find_element_by_xpath("//*[@id='selectProduct']/ul/li[4]")
            TouchActions(driver).tap(a3).perform()
            time.sleep(4)
            titlename = 14
            tagname = 0
            while titlename < 20:
                titlename1 = driver.find_elements_by_class_name("title")[titlename].text
                tagname1 = driver.find_elements_by_class_name("tag-top-right")[tagname].text
                title3 = titlename1 + tagname1
                if title3 == list_login[1]:
                    print(title3)
                    driver.find_elements_by_class_name("title")[titlename].click()
                    break
                else:
                    titlename = titlename + 1
                    tagname = tagname + 1
            time.sleep(3)

        if list_login[2] == "身份证":
            #点击身份证
            time.sleep(8)
            a4 = driver.find_element_by_xpath("//*[@id='applicantInfo']/section/div/ul/li[1]")
            time.sleep(1)
            TouchActions(driver).tap(a4).perform()
            time.sleep(2)
            insurance()
        elif list_login[2] == "护照":
            time.sleep(5)
            a17 = driver.find_element_by_xpath("//*[@id='applicantInfo']/section/div/ul/li[2]")
            TouchActions(driver).tap(a17).perform()
            time.sleep(2)
            insurance()
        elif list_login[2] == "军官证":
            time.sleep(5)
            a18 =driver.find_element_by_xpath("//*[@id='applicantInfo']/section/div/ul/li[3]")
            TouchActions(driver).tap(a18).perform()
            time.sleep(2)
            insurance()
        elif list_login[2] == "台胞证":
            time.sleep(5)
            a5 = driver.find_element_by_xpath("//*[@id='applicantInfo']/section/div/ul/li[4]/label")
            TouchActions(driver).tap(a5).perform()
            time.sleep(2)
            insurance()
        elif list_login[2] == "港澳回乡证":
            time.sleep(5)
            a19 = driver.find_element_by_xpath("//*[@id='applicantInfo']/section/div/ul/li[5]/label")
            TouchActions(driver).tap(a19).perform()
            time.sleep(2)
            insurance()
        #投保信息
        #点击修改保额
        a50 = WebDriverWait(driver,40,0.5).until(lambda x:x.find_element_by_xpath("//*[@id='productPremium']/section/section[3]/div[2]/section/div/div[2]/div/div[1]"))
        time.sleep(40)
        TouchActions(driver).tap(a50).perform()
        time.sleep(5)
        driver.find_element_by_name('num').clear()
        time.sleep(5)
        driver.find_element_by_name('num').send_keys(list_login[21])
        time.sleep(1)
        a41 = driver.find_element_by_css_selector(".btn.primary.btn-confirm")
        TouchActions(driver).tap(a41).perform()
        #添加附加险
        if list_login[22] == "有":
            driver.find_element_by_xpath("//*[@id='productPremium']/section/section[3]/div[2]/section/div/div[2]/div/div[2]/i").click()
            time.sleep(1)
            # driver.switch_to.context("NATIVE_APP")
            time.sleep(8)
            tagName = driver.find_element_by_css_selector(".product-list-premium-default.product-cards.clearfix").find_elements_by_tag_name("p")

            for tag in tagName:
                # print(tag.text)
                time.sleep(1)
                if '豁免' in tag.text:
                    pass
                else:
                    TouchActions(driver).tap(tag).perform()
            #点击确认
            time.sleep(2)
            a42 = driver.find_element_by_css_selector(".btn.primary.btn-confirm")
            TouchActions(driver).tap(a42).perform()
            time.sleep(8)
            #计算保费
            a43 = driver.find_element_by_css_selector(".btn.btn-submit.btn-save")
            TouchActions(driver).tap(a43).perform()
            time.sleep(10)
            a44 =driver.find_element_by_css_selector(".btn.btn-submit.btn-next")
            TouchActions(driver).tap(a44).perform()
            time.sleep(15)
            try:
                window = driver.find_element_by_css_selector(".btn.btn-lg.btn-submit.btn-confirm-confirm")
            except NoSuchElementException:
                print("没有弹窗")
            else:
                TouchActions(driver).tap(window).perform()
        else:
            #计算保费
            a45 = driver.find_element_by_css_selector(".btn.btn-submit.btn-save")
            TouchActions(driver).tap(a45).perform()
            time.sleep(10)
            a46 = driver.find_element_by_css_selector(".btn.btn-submit.btn-next")
            time.sleep(2)
            TouchActions(driver).tap(a46).perform()
            time.sleep(15)
            try:
                window1 = driver.find_element_by_css_selector(".btn.btn-lg.btn-submit.btn-confirm-confirm")
            except NoSuchElementException:
                print("没有弹窗")
            else:
                time.sleep(5)
                TouchActions(driver).tap(window1).perform()
        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
        time.sleep(10)
        driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[1]/div[1]/div[1]/p").click()
        #投保人信息
        a47 = WebDriverWait(driver, 20, 0.5).until(
            EC.presence_of_element_located((By.XPATH, "//*[@id='addInformation']/section/div[2]/div[1]/div[1]/div[1]")))
        TouchActions(driver).tap(a47).perform()
        # driver.tap([(470, 430)], 500)
        #婚姻状况
        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
        time.sleep(2)
        if list_login[23] == "未婚":
            driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/section/ul[1]/li[1]/div/label[1]").click()
        else:
            driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/section/ul[1]/li[1]/div/label[2]").click()
        time.sleep(1)
        driver.find_element_by_name("education").click()
        time.sleep(2)
        if list_login[24] == "博士":
            Select(driver.find_element_by_name("education")).select_by_value("11")
        elif list_login[24] == "硕士":
            Select(driver.find_element_by_name("education")).select_by_value("14")
        elif list_login[24] == "本科":
            Select(driver.find_element_by_name("education")).select_by_value("21")
        elif list_login[24] == "大专":
            Select(driver.find_element_by_name("education")).select_by_value("31")
        elif list_login[24] == "中专":
            Select(driver.find_element_by_name("education")).select_by_index("41")
        elif list_login[24] == "中技":
            Select(driver.find_element_by_name("education")).select_by_value("47")
        elif list_login[24] == "高中":
            Select(driver.find_element_by_name("education")).select_by_value("61")
        elif list_login[24] == "初中":
            Select(driver.find_element_by_name("education")).select_by_value("71")
        elif list_login[24] == "小学":
            Select(driver.find_element_by_name("education")).select_by_value("81")
        elif list_login[24] == "其他":
            Select(driver.find_element_by_name("education")).select_by_value("90")
        driver.find_element_by_name("nationality").click()
        time.sleep(1)
        if list_login[25] == '中国':
            Select(driver.find_element_by_name("nationality")).select_by_value("CHN")
        elif list_login[25] == '中国香港':
            Select(driver.find_element_by_name("nationality")).select_by_value("HKG")
        elif list_login[25] == '中国澳门':
            Select(driver.find_element_by_name("nationality")).select_by_value("MAC")
        elif list_login[25] == '中国台湾':
            Select(driver.find_element_by_name("nationality")).select_by_value("TWN")
        #个人年收入
        personincome = driver.find_element_by_name("personalIncome")
        print(personincome.get_attribute("value"))
        if personincome.get_attribute("value") == '':
            personincome.send_keys(list_login[26])
            # 家庭年收入
            driver.find_element_by_name("familyIncome").send_keys(list_login[27])
            time.sleep(1)
            #家庭地址
            a48 = driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/section/ul[2]/li[1]/div/input[4]")
            TouchActions(driver).tap(a48).perform()
            # driver.tap([(761, 913)], 500)
            driver.switch_to.context("NATIVE_APP")
            time.sleep(1)
            driver.swipe(357, 1000, 357, 200, 3500)
            time.sleep(1)
            driver.swipe(357, 1000, 357, 660, 3500)
            if list_login[28] == '广东省广州市天河区':
                driver.swipe(1633, 993, 1633, 800, 3500)
            elif list_login[28] == "广东省广州市海珠区":
                driver.swipe(1633, 993, 1633, 867, 3500)
            elif list_login[28] == "广东省广州市越秀区":
                driver.swipe(1633, 993, 1633, 936, 3500)
            time.sleep(2)
            driver.tap([(1820, 737)], 500)
            time.sleep(1)
            driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
            time.sleep(1)
            driver.find_element_by_name("familyAddrDetail").send_keys(list_login[29])
            #家庭邮编
            driver.find_element_by_name("familyPostcode").send_keys(list_login[30])
            #单位名称
            driver.find_element_by_name("unitName").send_keys(list_login[31])
            #单位地址
            driver.switch_to.context("NATIVE_APP")
            time.sleep(2)
            driver.tap([(747, 730)], 500)
            time.sleep(2)
            driver.swipe(357, 1000, 357, 200, 3500)
            time.sleep(1)
            driver.swipe(357, 1000, 357, 660, 3500)
            if list_login[32] == '广东省广州市天河区':
                driver.swipe(1633, 993, 1633, 800, 3500)
            elif list_login[32] == "广东省广州市海珠区":
                driver.swipe(1633, 993, 1633, 867, 3500)
            elif list_login[32] == "广东省广州市越秀区":
                driver.swipe(1633, 993, 1633, 936, 3500)
            time.sleep(2)
            driver.tap([(1820, 737)], 500)
            #单位详细地址
            driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
            time.sleep(1)
            driver.find_element_by_name("workAddrDetail").send_keys(list_login[33])
            #单位邮编
            driver.find_element_by_name("workPostcode").send_keys(list_login[34])
            #邮箱
            driver.find_element_by_name("email").send_keys(list_login[35])
            time.sleep(2)
            # action = TouchAction(driver)
            driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/div[2]/button[2]").click()
            # driver.switch_to.context("NATIVE_APP")
            # #点击确认
            # driver.tap([(1286, 1038)], 500)
            btn_confirm = driver.find_element_by_css_selector(".btn.primary.btn-confirm")
            TouchActions(driver).tap(btn_confirm).perform()
        else:
            btn_confirm = driver.find_element_by_css_selector(".btn.primary.btn-confirm")
            TouchActions(driver).tap(btn_confirm).perform()
        driver.switch_to.context("NATIVE_APP")
        time.sleep(3)
        if list_login[13] != "":
            time.sleep(3)
            swipeDown(1000)
            swipeDown(1000)
            time.sleep(2)
            #点击被保人
            driver.tap([(770, 412)], 500)
            TouchAction(driver).long_press(x=770,y=412).perform()
            time.sleep(1)
            # 被保人婚姻状况
            driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
            time.sleep(2)
            if list_login[36] == "未婚":
                driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/section/ul[1]/li[1]/div/label[1]").click()
            else:
                driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/section/ul[1]/li[1]/div/label[2]").click()
            time.sleep(1)
            driver.find_element_by_name("education").click()
            time.sleep(2)
            if list_login[37] == "博士":
                Select(driver.find_element_by_name("education")).select_by_value("11")
            elif list_login[37] == "硕士":
                Select(driver.find_element_by_name("education")).select_by_value("14")
            elif list_login[37] == "本科":
                Select(driver.find_element_by_name("education")).select_by_value("21")
            elif list_login[37] == "大专":
                Select(driver.find_element_by_name("education")).select_by_value("31")
            elif list_login[37] == "中专":
                Select(driver.find_element_by_name("education")).select_by_index("41")
            elif list_login[37] == "中技":
                Select(driver.find_element_by_name("education")).select_by_value("47")
            elif list_login[37] == "高中":
                Select(driver.find_element_by_name("education")).select_by_value("61")
            elif list_login[37] == "初中":
                Select(driver.find_element_by_name("education")).select_by_value("71")
            elif list_login[37] == "小学":
                Select(driver.find_element_by_name("education")).select_by_value("81")
            elif list_login[37] == "其他":
                Select(driver.find_element_by_name("education")).select_by_value("90")
            driver.find_element_by_name("nationality").click()
            time.sleep(1)
            if list_login[38] == '中国':
                Select(driver.find_element_by_name("nationality")).select_by_value("CHN")
            elif list_login[38] == '中国香港':
                Select(driver.find_element_by_name("nationality")).select_by_value("HKG")
            elif list_login[38] == '中国澳门':
                Select(driver.find_element_by_name("nationality")).select_by_value("MAC")
            elif list_login[38] == '中国台湾':
                Select(driver.find_element_by_name("nationality")).select_by_value("TWN")
            #被保人年收入
            driver.find_element_by_name("personalIncome").send_keys(list_login[62])
            # 家庭地址
            time.sleep(1)
            a6=driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/section/ul[2]/li[1]/div/input[4]")
            TouchActions(driver).tap(a6).perform()
            time.sleep(2)
            driver.switch_to.context("NATIVE_APP")
            time.sleep(1)
            driver.swipe(357, 1000, 357, 200, 3500)
            time.sleep(1)
            driver.swipe(357, 1000, 357, 660, 3500)
            time.sleep(1)
            if list_login[39] == '广东省广州市天河区':
                driver.swipe(1633, 993, 1633, 800, 3500)
            elif list_login[39] == "广东省广州市海珠区":
                driver.swipe(1633, 993, 1633, 867, 3500)
            elif list_login[39] == "广东省广州市越秀区":
                driver.swipe(1633, 993, 1633, 936, 3500)
                print("走这里了吗")
            time.sleep(2)
            driver.tap([(1820, 737)], 500)
            time.sleep(1)
            driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
            time.sleep(1)
            driver.find_element_by_name("familyAddrDetail").send_keys(list_login[40])
            # 家庭邮编
            driver.find_element_by_name("familyPostcode").send_keys(list_login[41])
            # 单位名称
            driver.find_element_by_name("unitName").send_keys(list_login[42])
            # 邮箱
            driver.find_element_by_name("email").send_keys(list_login[46])
            # 单位地址
            a7=driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/section/ul[3]/li[2]/div/input[4]")
            TouchActions(driver).tap(a7).perform()
            driver.switch_to.context("NATIVE_APP")
            time.sleep(1)
            driver.swipe(357, 1000, 357, 200, 3500)
            time.sleep(1)
            driver.swipe(357, 1000, 357, 660, 3500)
            driver.switch_to.context("NATIVE_APP")
            if list_login[43] == '广东省广州市天河区':
                driver.swipe(1633, 993, 1633, 800, 3500)
            elif list_login[43] == "广东省广州市海珠区":
                driver.swipe(1633, 993, 1633, 867, 3500)
            elif list_login[43] == "广东省广州市越秀区":
                driver.swipe(1633, 993, 1633, 936, 3500)
            time.sleep(2)
            driver.tap([(1820, 737)], 500)
            # 单位详细地址
            driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
            time.sleep(1)
            driver.find_element_by_name("workAddrDetail").send_keys(list_login[44])
            # 单位邮编
            driver.find_element_by_name("workPostcode").send_keys(list_login[45])
            time.sleep(2)
            # action = TouchAction(driver)
            driver.find_element_by_xpath(
                "//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/div[2]/button[2]").click()
            # 点击确认
            a8 =driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/div[2]/button[2]")
            TouchActions(driver).tap(a8).perform()
            driver.switch_to.context("NATIVE_APP")
            time.sleep(8)
            swipeDown(1000)
            swipeDown(1000)
            time.sleep(1)
            #受益人
            if list_login[63] == '法定受益人':
                driver.switch_to.context("NATIVE_APP")
                time.sleep(2)
                driver.tap([(1100, 419)], 500)
                time.sleep(5)
                driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
                time.sleep(2)
                a9= driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/seaction/div[1]/label[1]")
                TouchActions(driver).tap(a9).perform()
                time.sleep(2)
                a10 =driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/div/button")
                TouchActions(driver).tap(a10).perform()
            else:
                driver.switch_to.context("NATIVE_APP")
                time.sleep(2)
                driver.tap([(1100, 419)], 500)
                time.sleep(5)
                driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
                time.sleep(2)
                a60 = driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/seaction/div[1]/label[2]")
                TouchActions(driver).tap(a60).perform()
                time.sleep(2)
                #判断是否已有指定受益人，若有则直接选择
                try:
                    time.sleep(2)
                    personHe = driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/seaction/div[2]/div/div[1]")
                except NoSuchElementException:
                    print("pass")
                    a61 = driver.find_element_by_xpath(
                        "//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/seaction/div[2]/div/div/i")
                    TouchActions(driver).tap(a61).perform()
                    time.sleep(5)
                    # 证件类型
                    if list_login[64] == "父母":
                        a62 = driver.find_element_by_xpath(
                            "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/label[1]")
                        TouchActions(driver).tap(a62).perform()
                    elif list_login[64] == "配偶":
                        a62 = driver.find_element_by_xpath(
                            "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/label[2]")
                        TouchActions(driver).tap(a62).perform()
                    elif list_login[64] == "子女":
                        a62 = driver.find_element_by_xpath(
                            "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/label[3]")
                        TouchActions(driver).tap(a62).perform()
                    elif list_login[64] == "其他":
                        time.sleep(2)
                        a62 = driver.find_element_by_xpath(
                            "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/label[4]")
                        TouchActions(driver).tap(a62).perform()
                        time.sleep(2)
                        a63 = driver.find_element_by_name("relationDesc")
                        TouchActions(driver).tap(a63).perform()
                        if list_login[65] == "祖母":
                            a64 = driver.find_element_by_xpath(
                                "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/div/ul/li[1]")
                            TouchActions(driver).tap(a64).perform()
                        elif list_login[65] == "祖父":
                            a64 = driver.find_element_by_xpath(
                                "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/div/ul/li[2]")
                            TouchActions(driver).tap(a64).perform()
                        elif list_login[65] == "外祖母":
                            a64 = driver.find_element_by_xpath(
                                "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/div/ul/li[3]")
                            TouchActions(driver).tap(a64).perform()
                        elif list_login[65] == "外祖父":
                            a64 = driver.find_element_by_xpath(
                                "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/div/ul/li[4]")
                            TouchActions(driver).tap(a64).perform()
                    # 证件类型
                    if list_login[66] == '身份证':
                        a65 = driver.find_element_by_xpath(
                            "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[2]/div/label[1]")
                        TouchActions(driver).tap(a65).perform()
                    else:
                        pass
                    # 证件号
                    driver.find_element_by_name("identityCode").send_keys(list_login[67])
                    # 有效期
                    if list_login[68] == '长期':
                        driver.find_element_by_xpath(
                            "//*[@id='addInformation']/div[2]/div/section/ul[2]/li[2]/div[2]/label/input").click()
                    else:
                        js68 = "document.getElementById('popup-date-yxq').removeAttribute('readonly')"
                        driver.execute_script(js68)
                        time.sleep(2)
                        driver.find_element_by_id("popup-date-yxq").send_keys(list_login[68])
                    # 姓名
                    driver.find_element_by_xpath(
                        "//*[@id='addInformation']/div[2]/div/section/ul[2]/li[3]/input").send_keys(list_login[69])
                    time.sleep(2)
                    # 手机
                    driver.find_element_by_xpath(
                        "//*[@id='addInformation']/div[2]/div/section/ul[2]/li[6]/input").send_keys(list_login[72])
                    time.sleep(2)

                    try:
                        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
                        time.sleep(3)
                        confirmWindow2 = driver.find_element_by_css_selector(".customer-item")
                    except NoSuchElementException:
                        print("没有弹窗")
                        time.sleep(3)
                    else:
                        a69 = driver.find_elements_by_xpath("//*[@id='addInformation']/div[2]/div/div[2]/div/div[3]/button[1]")
                        TouchActions(driver).tap(a69).perform()
                        # TouchActions(driver).tap(confirmWindow2).perform()
                        # time.sleep(4)
                        # confirmWindow1 = driver.find_element_by_xpath(
                        #     "//*[@id='addInformation']/div[2]/div/div[2]/div/div[3]/button[2]")
                        # time.sleep(1)
                        # TouchActions(driver).tap(confirmWindow1).perform()
                    a68 = driver.find_element_by_xpath("//*[@id='addInformation']/div[2]/div/div[2]/button[2]")
                    TouchActions(driver).tap(a68).perform()
                    time.sleep(3)
                    driver.find_element_by_xpath(
                        "//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/seaction/div[2]/div/div[1]").click()
                    time.sleep(2)
                else:
                    TouchActions(driver).tap(personHe).perform()
                time.sleep(2)

                #平均分配
                a67 = driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/seaction/div[3]/div/button")
                TouchActions(driver).tap(a67).perform()
                time.sleep(2)
                #保存
                a66 =driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/div/button")
                TouchActions(driver).tap(a66).perform()
        else:
            swipeDown(1000)
            swipeDown(1000)
            time.sleep(2)
            # 受益人
            driver.switch_to.context("NATIVE_APP")
            if list_login[63] == '法定受益人':
                time.sleep(2)
                driver.tap([(765, 422)], 500)
                time.sleep(5)
                driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
                time.sleep(2)
                a9 = driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/seaction/div[1]/label[1]")
                TouchActions(driver).tap(a9).perform()
                time.sleep(2)
                a10 = driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/div/button")
                TouchActions(driver).tap(a10).perform()
            else:
                time.sleep(2)
                driver.tap([(765, 419)], 500)
                time.sleep(5)
                driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
                time.sleep(2)
                a60 = driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/seaction/div[1]/label[2]")
                TouchActions(driver).tap(a60).perform()
                time.sleep(2)
                # 判断是否已有指定受益人，若有则直接选择
                try:
                    time.sleep(2)
                    personHe = driver.find_element_by_xpath(
                        "//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/seaction/div[2]/div/div[1]/div/p")
                except NoSuchElementException:
                    print("pass")
                    a61 = driver.find_element_by_xpath(
                        "//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/seaction/div[2]/div/div/i")
                    TouchActions(driver).tap(a61).perform()
                    time.sleep(5)
                    # 证件类型
                    if list_login[64] == "父母":
                        a62 = driver.find_element_by_xpath(
                            "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/label[1]")
                        TouchActions(driver).tap(a62).perform()
                    elif list_login[64] == "配偶":
                        a62 = driver.find_element_by_xpath(
                            "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/label[2]")
                        TouchActions(driver).tap(a62).perform()
                    elif list_login[64] == "子女":
                        a62 = driver.find_element_by_xpath(
                            "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/label[3]")
                        TouchActions(driver).tap(a62).perform()
                    elif list_login[64] == "其他":
                        time.sleep(2)
                        a62 = driver.find_element_by_xpath(
                            "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/label[4]")
                        TouchActions(driver).tap(a62).perform()
                        time.sleep(2)
                        a63 = driver.find_element_by_name("relationDesc")
                        TouchActions(driver).tap(a63).perform()
                        if list_login[65] == "祖母":
                            a64 = driver.find_element_by_xpath(
                                "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/div/ul/li[1]")
                            TouchActions(driver).tap(a64).perform()
                        elif list_login[65] == "祖父":
                            a64 = driver.find_element_by_xpath(
                                "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/div/ul/li[2]")
                            TouchActions(driver).tap(a64).perform()
                        elif list_login[65] == "外祖母":
                            a64 = driver.find_element_by_xpath(
                                "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/div/ul/li[3]")
                            TouchActions(driver).tap(a64).perform()
                        elif list_login[65] == "外祖父":
                            a64 = driver.find_element_by_xpath(
                                "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[1]/div/div/ul/li[4]")
                            TouchActions(driver).tap(a64).perform()
                    # 证件类型
                    if list_login[66] == '身份证':
                        a65 = driver.find_element_by_xpath(
                            "//*[@id='addInformation']/div[2]/div/section/ul[1]/li[2]/div/label[1]")
                        TouchActions(driver).tap(a65).perform()
                    else:
                        pass
                    # 证件号
                    driver.find_element_by_name("identityCode").send_keys(list_login[67])
                    # 有效期
                    if list_login[68] == '长期':
                        driver.find_element_by_xpath(
                            "//*[@id='addInformation']/div[2]/div/section/ul[2]/li[2]/div[2]/label/input").click()
                    else:
                        js68 = "document.getElementById('popup-date-yxq').removeAttribute('readonly')"
                        driver.execute_script(js68)
                        time.sleep(2)
                        driver.find_element_by_id("popup-date-yxq").send_keys(list_login[68])
                    # 姓名
                    driver.find_element_by_xpath(
                        "//*[@id='addInformation']/div[2]/div/section/ul[2]/li[3]/input").send_keys(list_login[69])
                    time.sleep(2)
                    # 手机
                    driver.find_element_by_xpath(
                        "//*[@id='addInformation']/div[2]/div/section/ul[2]/li[6]/input").send_keys(list_login[72])
                    time.sleep(2)
                    try:
                        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
                        time.sleep(3)
                        confirmWindow2 = driver.find_element_by_css_selector(".customer-item")
                    except NoSuchElementException:
                        print("没有弹窗")
                        time.sleep(3)
                    else:
                        # TouchActions(driver).tap(confirmWindow2).perform()
                        # time.sleep(4)
                        # confirmWindow1 = driver.find_element_by_xpath(
                        #     "//*[@id='addInformation']/div[2]/div/div[2]/div/div[3]/button[2]")
                        # time.sleep(1)
                        # TouchActions(driver).tap(confirmWindow1).perform()
                        a70 =driver.find_element_by_xpath("//*[@id='addInformation']/div[2]/div/div[2]/div/div[3]/button[1]")
                        TouchActions(driver).tap(a70).perform()
                    a68 = driver.find_element_by_xpath("//*[@id='addInformation']/div[2]/div/div[2]/button[2]")
                    TouchActions(driver).tap(a68).perform()
                    time.sleep(3)
                    driver.find_element_by_xpath(
                        "//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/seaction/div[2]/div/div[1]").click()
                    time.sleep(2)
                else:
                    TouchActions(driver).tap(personHe).perform()
                time.sleep(2)

                # 平均分配
                a67 = driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/seaction/div[3]/div/button")
                TouchActions(driver).tap(a67).perform()
                time.sleep(2)
                # 保存
                a66 = driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[1]/div[2]/div/div/button")
                TouchActions(driver).tap(a66).perform()
        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
        time.sleep(2)
        #输入投保人手机号及验证码
        # driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[2]/div[1]/div/input").send_keys(list_login[48])
        insTel = driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[2]/div[1]/div/input")
        if insTel.get_attribute("value") == '':
            insTel.send_keys(list_login[48])
        else:
            pass
        driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[2]/div[1]/div/p/span").click()
        driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[2]/div[1]/div/p/input").send_keys("999999")
        time.sleep(2)
        #输入被保人手机号及验证码
        if list_login[49] != '':
            driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[2]/div[2]/div/input").send_keys(list_login[49])
            driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[2]/div[2]/div/p/span").click()
            driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[2]/div[2]/div/p/input").send_keys("999999")
        else:
            print("无被保人")
        driver.switch_to.context("NATIVE_APP")
        time.sleep(1)
        swipeUp(1000)
        time.sleep(1)
        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
        time.sleep(2)
        try:
            inns = driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[3]/div[1]/div[1]/div/select")
            inns.click()
            if list_login[50] == "自动垫付":
                driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[3]/div[1]/div[1]/div/select/option[2]").click()
            else:
                driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[3]/div[1]/div[1]/div/select/option[3]").click()
        except Exception:
            pass
        #现金红利处理方式
        try:
            cash =driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[3]/div[1]/div[2]/div/select")
            cash.click()
            time.sleep(1)
            if list_login[51] == "累计生息":
                driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[3]/div[1]/div[2]/div/select/option[2]").click()
            elif list_login[51] == "现金领取":
                driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[3]/div[1]/div[2]/div/select/option[3]").click()
            elif list_login[51] == "抵缴保费":
                driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[3]/div[1]/div[2]/div/select/option[4]").click()
        except Exception:
            pass
            #raise Exception("Element not found.")

        # 年金处理方式
        try:
            annuity = driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[3]/div[1]/div[3]/div/select")
            annuity.click()
            time.sleep(1)
            if list_login[52] == "累计生息":
                driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[3]/div[1]/div[3]/div/select/option[2]").click()
            elif list_login[52] == "现金领取":
                driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[3]/div[1]/div[3]/div/select/option[3]").click()
            elif list_login[52] == "抵缴保费":
                driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[3]/div[1]/div[3]/div/select/option[4]").click()
        except Exception:
            #raise Exception("Element not found.")
            pass
        # 生存金处理方式
        try:
            survival =driver.find_element_by_xpath("//*[@id='addInformation']/section/div[2]/div[3]/div[1]/div[4]/div/select")
            survival.click()
            time.sleep(1)
            if list_login[53] == "累计生息":
                driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[3]/div[1]/div[4]/div/select/option[2]").click()
            elif list_login[53] == "现金领取":
                driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[3]/div[1]/div[4]/div/select/option[3]").click()
            elif list_login[53] == "抵缴保费":
                driver.find_element_by_xpath(
                    "//*[@id='addInformation']/section/div[2]/div[3]/div[1]/div[4]/div/select/option[4]").click()
        except Exception:
            pass
            #raise Exception("Element not found.")

        #保单通讯地址
        time.sleep(1)
        driver.switch_to.context("NATIVE_APP")
        time.sleep(1)
        #点一下其他地方
        driver.tap([(1195, 603)], 500)
        time.sleep(1)
        #点击地址+号
        # driver.tap([(672,936)],500)
        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
        time.sleep(2)
        addre=driver.find_element_by_xpath("//div[@class='add-address-wrap']/div[1]/p[1]/i")
        TouchActions(driver).tap(addre).perform()
        time.sleep(7)
        a49 = WebDriverWait(driver, 20, 0.5).until(EC.presence_of_element_located(
            (By.XPATH, "//*[@id='addInformation']/section/div[2]/div[3]/div[2]/div[1]/div/div[2]/div[1]/div[1]")))
        a49.click()
        time.sleep(2)
        #告知问卷
        time.sleep(1)
        driver.switch_to.context("NATIVE_APP")
        swipeUp(1000)
        time.sleep(1)
        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
        time.sleep(2)
        try:
            tips = driver.find_element_by_xpath("//*[text()='人身投保提示书-营销员渠道']")
        except NoSuchElementException:
            print("无人身投保提示书告知")
        else:
            time.sleep(3)
            TouchActions(driver).tap(tips).perform()
            time.sleep(7)
            driver.find_element_by_xpath("//*[@id='getQuestionData']/div/div[2]/p/label/input").click()
            driver.switch_to.context("NATIVE_APP")
            time.sleep(1)
            driver.tap([(1723, 1143)], 500)
            time.sleep(5)
            driver.tap([(1723, 1143)], 500)
            time.sleep(5)
        try:
            time.sleep(1)
            driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
            time.sleep(2)
            shuishou = driver.find_element_by_xpath("//*[text()='个人税收居民身份声明']")
        except NoSuchElementException:
            print("无个人税收居民身份声明")
        else:
            if shuishou.is_displayed():
                time.sleep(2)
                TouchActions(driver).tap(shuishou).perform()
                time.sleep(2)
                driver.find_element_by_name("N1140001").click()
                if list_login[25] == '中国':
                    time.sleep(1)
                    driver.find_element_by_xpath("//*[@id='getQuestionData']/div/div/div/select/option[2]").click()
                else:
                    #非居民
                    driver.find_element_by_xpath("//*[@id='getQuestionData']/div/div/div/select/option[3]").click()
                    time.sleep(1)
                    driver.find_element_by_name("N1140001_N1140002").click()
                    time.sleep(1)
                    if list_login[25] == '中国台湾':
                        driver.find_element_by_xpath("//*[@id='getQuestionData']/div/div/div[2]/div[1]/div/select/option[5]").click()
                        time.sleep(2)
                        driver.switch_to.context("NATIVE_APP")
                        time.sleep(1)
                        driver.tap([(1595, 168)], 500)
                        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
                        time.sleep(1)
                        driver.find_element_by_name("N1140001_N1140003_c0_N114000301").click()
                        time.sleep(1)
                        driver.find_element_by_xpath("//*[@id='getQuestionData']/div/div/div[2]/div[2]/div[1]/div/div/div[1]/div/select/option[5]").click()
                    elif list_login[25] == '中国香港':
                        driver.find_element_by_xpath("//*[@id='getQuestionData']/div/div/div[2]/div[1]/div/select/option[3]").click()
                        time.sleep(1)
                        driver.switch_to.context("NATIVE_APP")
                        time.sleep(1)
                        driver.tap([(1595, 168)], 500)
                        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
                        time.sleep(1)
                        driver.find_element_by_name("N1140001_N1140003_c0_N114000301").click()
                        time.sleep(1)
                        driver.find_element_by_xpath(
                            "//*[@id='getQuestionData']/div/div/div[2]/div[2]/div[1]/div/div/div[1]/div/select/option[3]").click()
                    elif list_login[25] == '中国澳门':
                        driver.find_element_by_xpath(
                            "//*[@id='getQuestionData']/div/div/div[2]/div[1]/div/select/option[4]").click()
                        driver.switch_to.context("NATIVE_APP")
                        time.sleep(1)
                        driver.tap([(1595, 168)], 500)
                        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
                        time.sleep(1)
                        driver.find_element_by_name("N1140001_N1140003_c0_N114000301").click()
                        time.sleep(1)
                        driver.find_element_by_xpath(
                            "//*[@id='getQuestionData']/div/div/div[2]/div[2]/div[1]/div/div/div[1]/div/select/option[4]").click()
                    time.sleep(2)
                    driver.find_elements_by_name("N1140001_N1140003_c0_N114000302")[1].click()
                    time.sleep(1)
                    driver.find_elements_by_name("N1140001_N1140003_c0_N114000302_N11400030202")[0].click()
                driver.switch_to.context("NATIVE_APP")
                time.sleep(1)
                driver.tap([(1723, 1143)], 500)
                time.sleep(5)
                driver.tap([(1723, 1143)], 500)
                time.sleep(5)
            else:
                pass
        #基本告知sio
        try:
            time.sleep(3)
            driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
            kown = driver.find_element_by_xpath("//*[text()='基本告知(SIO)']")
        except NoSuchElementException:
            print("没有基本告知（SIO）")
        else:
            TouchActions(driver).tap(kown).perform()
            time.sleep(5)
            driver.find_element_by_xpath("//*[@id='getQuestionData']/div/div[1]/div/label[2]/input").click()
            driver.find_element_by_xpath("//*[@id='getQuestionData']/div/div[2]/div/label[2]/input").click()
            driver.find_element_by_xpath("//*[@id='getQuestionData']/div/div[3]/div/label[2]/input").click()
            driver.find_element_by_xpath("//*[@id='getQuestionData']/div/div[4]/div/label[2]/input").click()
            driver.find_element_by_xpath("//*[@id='getQuestionData']/div/div[5]/div/label[2]/input").click()
            driver.find_element_by_xpath("//*[@id='getQuestionData']/div/div[6]/div/label[2]/input").click()
            driver.find_element_by_xpath("//*[@id='getQuestionData']/div/div[7]/div/label[2]/input").click()
            driver.find_element_by_xpath("//*[@id='getQuestionData']/div/div[8]/div/label[2]/input").click()
            time.sleep(1)
            driver.switch_to.context("NATIVE_APP")
            time.sleep(1)
            driver.tap([(1723, 1143)], 500)
            time.sleep(5)
            driver.tap([(1723, 1143)], 500)
            time.sleep(10)
        #基本告知
        try:
            driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
            time.sleep(1)
            basickown = driver.find_element_by_xpath("//*[text()='基本告知']")
        except NoSuchElementException:
            print("没有基本告知")
        else:
            time.sleep(1)
            TouchActions(driver).tap(basickown).perform()
            time.sleep(5)
            #  除本公司产品外，是否已购买或正在申请其它保险公司的人身保险合同？
            driver.find_elements_by_name("N0010001")[1].click()
            #  您是否拥有公费医疗、社会医疗保险、其它商业保险公司提供的费用补偿型医疗保险或本公司认可的费用补偿型医疗保险？
            driver.find_elements_by_name("N0010007")[1].click()
            #  您是否正在或试图参加私人性质飞行，或携带氧气瓶潜水、或登山、或从事危险性的运动？
            driver.find_elements_by_name("N0010008")[1].click()
            #  PA单：您是否正计划前往其它国家或海外地区旅行、工作或居住？
            driver.find_elements_by_name("N0010009")[1].click()
            if list_login[15] == '女':
            #  您目前是否怀孕？
                driver.find_elements_by_name("N0050001")[1].click()
            # 是否曾患有或被告知患有任何子宫、宫颈、输卵管、阴道、卵巢或乳房之疾病或失调，或因怀孕而导致并发症，如高血压、糖尿病等；
                driver.find_elements_by_name("N0050003")[1].click()
            elif list_login[7] == '女' and list_login[9] == '本人':
                driver.find_elements_by_name("N0050001")[1].click()
                driver.find_elements_by_name("N0050003")[1].click()
            else:
                pass
            #身高
            driver.find_element_by_name("N0030001").send_keys("165")
            #体重
            driver.find_element_by_name("N0030002").send_keys("55")
            # 过去一年内是否有体重增/减大于 5 公斤
            driver.find_elements_by_name("N0030003")[1].click()
            # A、接受或被建议接受以下检查，且检查结果有异常；
            driver.find_elements_by_name("N003002001")[1].click()
            # B、接受输血或捐血而不被接受；
            driver.find_elements_by_name("N003002002")[1].click()
            # C、接受或被建议接受检查诊疗、手术、住院治疗；
            driver.find_elements_by_name("N003002003")[1].click()
            # D、接受任何药物治疗或医疗护理；
            driver.find_elements_by_name("N003002004")[1].click()
            #   11.  您是否有身体残障情况：
            driver.find_elements_by_name("N003003001")[1].click()
            driver.find_elements_by_name("N003003002")[1].click()
            driver.find_elements_by_name("N003003003")[1].click()
            #   12.  A、与心脑等循环系統疾病有关的疾病，如风湿性心脏病、高血压、心肌梗塞、脑血管意外（中风或出血等）、先天性或缺血性心脏病；
            driver.find_elements_by_name("N003004001")[1].click()
            # 13.  B、血液有关的疾病如血友病、贫血、白血病、紫癲等疾病；
            driver.find_elements_by_name("N003004002")[1].click()
            #14.   C、五官有关的疾病，如高度近视、青光眼、白内障、失明、视网膜出血或剥离、眼底病变、耳鼻喉或口腔疾病等
            driver.find_elements_by_name("N003004003")[1].click()
            # 15.  D、消化系統有关的疾病，如消化道溃疡或出血穿孔、肛管疾病、疝气、胰腺炎、肝病； （若为乙型肝炎，请注明）；
            driver.find_elements_by_name("N003004004")[1].click()
            # 16.  E、泌尿系统有关的疾病，如膀胱疾病、肾病、肾结石、肾炎等；
            driver.find_elements_by_name("N003004005")[1].click()
            # 17.  F、呼吸系統疾病如哮喘、支气管炎、肺气肿、肺扩张或肺結核；
            driver.find_elements_by_name("N003004006")[1].click()
            # 18.  G、肌肉或骨骼有关的毛病，如各类关节炎、瘫瘓、痛风、脊椎疾病、畸形、肢体被切除或严重受伤；
            driver.find_elements_by_name("N003004007")[1].click()
            # 19.  H、神经系统及免疫系统疾病，如精神病、震颤、眩晕、酒精或药物滥用成瘾、癫痫、智障、帕金森综合征或精神不正常，系统性红斑狼疮、多发性硬化症、硬皮病等；
            driver.find_elements_by_name("N003004008")[1].click()
            # 20.  I、癌症、肿瘤、息肉、囊肿、任何透过性接触传染的疾病、HIV 感染、后天免疫能力缺乏症（艾滋病）或艾滋病并发症；
            driver.find_elements_by_name("N003004009")[1].click()
            # 21.  J、糖尿病、痛风、甲状腺疾病（如甲状腺结节、甲状腺功能亢进或减退）
            driver.find_elements_by_name("N003004010")[1].click()
            # 22.  K、是否还有其他以上未提及的疾病及症状，而需要接受检查、治疗或住院？
            driver.find_elements_by_name("N003004011")[1].click()
            # 23.  您的配偶是否曾接受或试图接受与艾滋病（AIDS）有关的医疗咨询、检查或治疗；
            driver.find_elements_by_name("N0030075")[1].click()
            # 24.  是否曾在过去 6 个月内持续一周以上有下列症状：
            driver.find_elements_by_name("N0030076")[1].click()
            # 25.  您的家属（父母、兄弟姐妹）是否曾患有或正患有以下疾病（高血压、肾病、心脏病、
            # 肝肾囊肿、肝硬化、糖尿病、精神病、白血病、结核病、多发性硬化症、癌症或其它急慢性重大疾病）
            driver.find_elements_by_name("N0030080")[1].click()
            # 26.  您是否吸烟或曾吸烟
            driver.find_elements_by_name("N0040001")[1].click()
            # 27.  您是否有或曾有饮酒的习惯？
            driver.find_elements_by_name("N0040005")[1].click()
            # 13.  您的人寿保险、意外伤害保险或健康保险的新单申请或复效是否曾被拒保、推迟、加费或做任何形式修改？
            driver.find_elements_by_name("N0010003")[1].click()
            #您是否曾向任何保险公司提出过索赔申请？
            driver.find_elements_by_name("N0010005")[1].click()
            driver.switch_to.context("NATIVE_APP")
            time.sleep(1)
            driver.tap([(1723, 1143)], 500)
            time.sleep(8)
            driver.tap([(1723, 1143)], 500)
            time.sleep(15)
        try:
            driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
            time.sleep(2)
            highPremium = driver.find_element_by_xpath("//*[text()='高保额高保费问卷']")
        except NoSuchElementException:
            print("没有高保额高保费问卷")
            time.sleep(3)
        else:
            TouchActions(driver).tap(highPremium).perform()
            time.sleep(8)
            driver.find_elements_by_name("F0010004")[1].click()
            driver.switch_to.context("NATIVE_APP")
            time.sleep(1)
            driver.tap([(1723, 1143)], 500)
            time.sleep(5)
            driver.tap([(1723, 1143)], 500)
            time.sleep(10)
        try:
            driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
            time.sleep(2)
            basickownGIO = driver.find_element_by_xpath("//*[text()='基本告知(GIO)']")
        except NoSuchElementException:
            print("没有基本告知GIO")
            time.sleep(3)
        else:
            TouchActions(driver).tap(basickownGIO).perform()
            time.sleep(8)
            driver.find_elements_by_name("N0100001")[1].click()
            driver.find_elements_by_name("N0100002")[1].click()
            driver.switch_to.context("NATIVE_APP")
            time.sleep(1)
            driver.tap([(1723, 1143)], 500)
            time.sleep(5)
            driver.tap([(1723, 1143)], 500)
            time.sleep(10)

        #点击下一步
        time.sleep(1)
        driver.switch_to.context("NATIVE_APP")
        time.sleep(8)
        driver.tap([(1723, 1143)], 500)
        time.sleep(15)
        try:
            driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
            time.sleep(3)
            confirmWindow = driver.find_element_by_css_selector(".btn.btn-lg.btn-submit.btn-confirm-confirm")
        except NoSuchElementException:
            print("没有弹窗")
            time.sleep(3)
        else:
            TouchActions(driver).tap(confirmWindow).perform()
        #缴费方式
        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
        time.sleep(10)
        a11 = driver.find_element_by_xpath("//*[@id='payment']/div[1]/div[2]/div[1]/div/div")
        TouchActions(driver).tap(a11).perform()
        time.sleep(1)
        #账户持有人
        driver.find_element_by_xpath("//*[@id='payment']/div[1]/div[2]/div[2]/div[1]/section/ul/ul/li[1]/div/select").click()
        driver.find_element_by_xpath("//*[@id='payment']/div[1]/div[2]/div[2]/div[1]/section/ul/ul/li[1]/div/select/option[2]").click()
        #银行名称
        driver.find_element_by_name("bankCode").click()
        if list_login[55] == "中国银行":
            Select(driver.find_element_by_name("bankCode")).select_by_value("104")
        elif list_login[55] == "中国工商银行":
            Select(driver.find_element_by_name("bankCode")).select_by_value("102")
        elif list_login[55] == "中国建设银行":
            Select(driver.find_element_by_name("bankCode")).select_by_value("105")
        elif list_login[55] == "招商银行":
            Select(driver.find_element_by_name("bankCode")).select_by_value("308")
        elif list_login[55] == "交通银行":
            Select(driver.find_element_by_name("bankCode")).select_by_value("301")
        elif list_login[55] == "中国农业银行":
            Select(driver.find_element_by_name("bankCode")).select_by_value("103")
        #银行卡类型
        driver.find_element_by_name("bankTypeCode").click()
        if list_login[56] == "储蓄卡":
            Select(driver.find_element_by_name("bankTypeCode")).select_by_value("0")
        else:
            Select(driver.find_element_by_name("bankTypeCode")).select_by_value("1")
        #银行卡号
        driver.find_element_by_name("bankNo").send_keys(list_login[57])
        time.sleep(1)
        #确认按钮
        driver.find_element_by_xpath("//*[@id='payment']/div[1]/div[2]/div[2]/div[2]/button[2]").click()
        time.sleep(8)
        driver.find_element_by_css_selector(".bank-info.bank-104").click()
        # #选择银行
        # driver.find_element_by_xpath("//*[@id='payment']/div[1]/div[2]/div[2]/div[1]/div/div/div/div").click()
        # driver.switch_to.context("NATIVE_APP")
        driver.switch_to.context("NATIVE_APP")
        time.sleep(1)
        swipeUp(1000)
        #判断是否有续期缴费
        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
        time.sleep(2)
        try:
            a14 = driver.find_element_by_xpath("//*[text()='请选择续期缴费']")
        except NoSuchElementException:
            print("无续期缴费")
        else:
            time.sleep(2)
            driver.find_elements_by_css_selector(".icon-add-box.icon-add")[1].click()
            time.sleep(4)
            driver.find_elements_by_css_selector(".bank-info.bank-104")[1].click()

        #判断是否有收款账户
        try:
            payment= driver.find_element_by_xpath("//*[text()='请选择收益收款账户']")
            payment1 = driver.find_element_by_xpath("//*[text()='投保人']")
        except NoSuchElementException:
            print('no cancelBtn')   #当没有这个元素就打印出no cancelBtn
        else:
            time.sleep(4)
            driver.find_elements_by_css_selector(".icon-add-box.icon-add")[2].click()
            time.sleep(4)
            driver.find_elements_by_css_selector(".bank-info.bank-104")[2].click()
        time.sleep(1)
        #判断是否有被保人收款账号
        try:
            payment2 = driver.find_element_by_xpath("//*[text()='被保人']")
        except NoSuchElementException:
            print('no cancelBtn')  # 当没有这个元素就打印出no cancelBtn
        else:
            time.sleep(2)
            driver.find_elements_by_css_selector(".icon-add-box.icon-add")[3].click()
            # 账户持有人
            driver.find_element_by_xpath(
                "//*[@id='payment']/div[1]/div[5]/div[2]/div[2]/div[1]/section/ul/ul/li[1]/div/select").click()
            driver.find_element_by_xpath(
                "//*[@id='payment']/div[1]/div[5]/div[2]/div[2]/div[1]/section/ul/ul/li[1]/div/select/option[3]").click()
            # 银行名称
            driver.find_element_by_name("bankCode").click()
            if list_login[59] == "中国银行":
                Select(driver.find_element_by_name("bankCode")).select_by_value("104")
            elif list_login[59] == "中国工商银行":
                Select(driver.find_element_by_name("bankCode")).select_by_value("102")
            elif list_login[59] == "中国建设银行":
                Select(driver.find_element_by_name("bankCode")).select_by_value("105")
            elif list_login[59] == "招商银行":
                Select(driver.find_element_by_name("bankCode")).select_by_value("308")
            elif list_login[59] == "交通银行":
                Select(driver.find_element_by_name("bankCode")).select_by_value("301")
            elif list_login[59] == "中国农业银行":
                Select(driver.find_element_by_name("bankCode")).select_by_value("103")
            # 银行卡类型
            driver.find_element_by_name("bankTypeCode").click()
            if list_login[60] == "储蓄卡":
                Select(driver.find_element_by_name("bankTypeCode")).select_by_value("0")
            else:
                Select(driver.find_element_by_name("bankTypeCode")).select_by_value("1")
            # 银行卡号
            driver.find_element_by_name("bankNo").send_keys(list_login[61])
            time.sleep(1)
            #点击确认
            driver.find_element_by_xpath("//*[@id='payment']/div[1]/div[5]/div[2]/div[2]/div[2]/button[2]").click()
            time.sleep(1)
            time.sleep(4)
            driver.find_elements_by_css_selector(".bank-info.bank-105")[0].click()
        driver.switch_to.context("NATIVE_APP")
        time.sleep(5)
        driver.tap([(1686, 1149)], 500)
        time.sleep(15)
        driver.tap([(1686, 1149)], 500)
        time.sleep(15)

        #获取保单号
        driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
        time.sleep(25)
        assid = driver.find_element_by_xpath("//*[@id='pageMain']/div[2]/div/div[1]/em")
        assidtext =assid.text
        print(assidtext)
        sheet1.write(row1,0,list_login[3])
        sheet1.write(row1,1,list_login[5])
        sheet1.write(row1,2,assidtext)
        sheet1.write(row1,3,list_login[0])
        sheet1.write(row1,4,list_login[1])
        workbook.save("D:\\workspace\\smart\\venv1\\Result\\"+localtime+".xls")
        row1= row1+1
        #如有被保人签名
        driver.switch_to.context("NATIVE_APP")
        time.sleep(3)
        driver.tap([(917, 534)], 500)
        time.sleep(1)
        driver.swipe(574,516,1019,690,3000)
        time.sleep(1)
        driver.tap([(1436, 1138)], 500)
        time.sleep(3)
        #代理人签名
        try:
            driver.switch_to.context("WEBVIEW_cn.com.fwd.eapp.uat")
            time.sleep(1)
            dailiren = driver.find_element_by_xpath("//*[@id='pageMain']/div[2]/div/ul/li[3]/p")
        except NoSuchElementException:
            print('no cancelBtn')  # 当没有这个元素就打印出no cancelBtn
        else:
            driver.switch_to.context("NATIVE_APP")
            time.sleep(1)
            driver.tap([(1534, 533)], 500)
            time.sleep(1)
            driver.swipe(574, 516, 1019, 690, 3000)
            time.sleep(1)
            driver.tap([(1436, 1138)], 500)

        #投保人签名
        driver.switch_to.context("NATIVE_APP")
        time.sleep(3)
        driver.tap([(321, 548)],500)
        time.sleep(2)
        driver.swipe(574,516,1019,690,3000)
        time.sleep(1)
        driver.tap([(1436, 1138)], 500)
        #点击支付
        time.sleep(8)
        driver.tap([(1718, 1145)], 500)
        time.sleep(20)
        #点击到投保选择页面
        time.sleep(10)
        driver.tap([(114, 61)], 500)
        time.sleep(6)
    except Exception:
        traceback.print_exc()
        driver.switch_to.context("NATIVE_APP")
        time.sleep(1)
        filepath = "D:\\workspace\\smart\\venv1\\Result\\screenshot\\" + localtime
        print(filepath)
        if not os.path.exists(filepath):
            os.makedirs(filepath)
        # driver.get_screenshot_as_file("D:\\workspace\\smartproject\\venv1\\Result\\screenshot\\" + localtime + ""+str(row1)+".png")
        # driver.get_screenshot_as_file( + filepath + "\\" + str(row1) + ".png")
        driver.get_screenshot_as_file(filepath + "\\" + str(row1) + ".png")

        pass
        driver.quit()
        time.sleep(5)
        desired_caps = {}
        desired_caps['platformName'] = 'Android'
        desired_caps['version'] = '7.1.1'
        desired_caps['deviceName'] = 'HGAFQ94U'  # 这是测试机的型号，可以查看手机的关于本机选项获得
        desired_caps['unicodeKeyboard'] = 'true'  # 使用unicode编码方式发送字符串
        desired_caps['resetKeyboard'] = 'true'  # 隐藏键盘
        # desired_caps['app'] = PATH('D:\\qq.apk')#被测试的App在电脑上的位置
        desired_caps['recreateChromeDriverSessions'] = 'True'
        desired_caps['appPackage'] = 'cn.com.fwd.eapp.uat'
        desired_caps['appActivity'] = 'cn.com.fwd.eapp.uat.activity.SplashActivity'
        # desired_caps['chromedriverExecutableDir'] = r'D:\workspace\webdriver\chrome\2.18'

        driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
        time.sleep(2)
        # 选择环境
        ell = driver.find_element_by_xpath \
            (
                "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.support.v7.widget.LinearLayoutCompat/android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.EditText")
        ell.click()
        ell.send_keys("4")
        # driver.hide_keyboard()
        time.sleep(2)
        ell2 = driver.find_element_by_id("android:id/button1")
        ell2.click()
        # 输入用户名密码
        time.sleep(1)
        webview = driver.contexts
        view = webview[1]
        driver.switch_to.context(view)
        new_view = driver.current_context
        driver.find_element_by_id("account").send_keys("10000796")
        driver.find_element_by_id("password").send_keys("080092")
        time.sleep(2)
        # driver.hide_keyboard()
        driver.find_element_by_xpath("//*[@id='formLogin']/button").click()
        time.sleep(8)


m = SendMail(
username='460690837@qq.com',
passwd='yyydlbasiilxbjeg',
recv=['patrick.yue@fwd.com','tracy.wang@fwd.com'],
title=localtime,
content='本次执行的结果见附件',
file= "D:\\workspace\\smart\\venv1\\Result\\"+localtime+".xls",
ssl=True,)
m.send_mail()



